import axios from 'axios';

const API_BASE_URL = '/api/config/behavior-sentences';

// Helper function to convert fields for the backend
const convertToBackendFields = (data) => {
  return {
    sentence: data.sentence,
    is_enabled: data.is_enabled,
    behavior_type: data.behavior_type,
    time_period: data.time_period,
  };
};

export default {
  // GET /config/behavior-sentences
  getBehaviorSentences() {
    return axios.get(API_BASE_URL);
  },

  // POST /config/behavior-sentences
  addBehaviorSentence(data) {
    return axios.post(API_BASE_URL, convertToBackendFields(data));
  },

  // PUT /config/behavior-sentences/{id}
  updateBehaviorSentence(id, data) {
    return axios.put(`${API_BASE_URL}/${id}`, convertToBackendFields(data));
  },

  // DELETE /config/behavior-sentences/{id}
  deleteBehaviorSentence(id) {
    return axios.delete(`${API_BASE_URL}/${id}`);
  }
};
